
     var ju = document.querySelector(".b-top-hint")
     console.log(ju);
     var b_top_color = document.querySelectorAll(".b-top")
     var txt = document.querySelector(".b-top .input1")
     var pass = document.querySelector(".b-top .input2")
     var sub = document.querySelector(".b-bottom input")
     console.log(sub);
        sub.onclick = function(){
        if (txt.value == "") {
            ju.style.display = "block"
            b_top_color[0].className = "b-top b-top-color"
            ju.className = "b-top-hint"
            return false;
        }
        if (pass.value == "") {
            ju.style.display = "block"
            b_top_color[1].className = "b-top b-top-color"
            ju.innerHTML = "<i><img src="+'./images/hint.jpg'+"><span>请输入密码</span></i>"
            return false;
        }
    }
    $(function () {
        $("form").on("submit", function () {
            let data = $("form").serialize();

            $.ajax({
                url: "./api/login",
                type: "post",
                data: data
            }).then(function (res) {
                console.log(res);
                layer.msg(res.message);
                if(res.code == 200) {
                    //就需要把当前的登陆者的信息,保存到本地
                    localStorage.setItem("userInfo",JSON.stringify(res.data));
                    setTimeout(function () {
                        location="./index.html"
                    },1000)
                }
            })




            return false;
        })
    })
    
